﻿using B.MES.Customer.Domain.DTO;
using DotNetCore.CAP;
using EventBusEto.Order;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Mysqlx.Crud;

namespace B.MES.Customer.Read.WebApi.Controllers
{
    /// <summary>
    /// 消费者管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CustomerController : ControllerBase
    {
        /// <summary>
        /// 注入服务
        /// </summary>
        private readonly IServiceCollection _services;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="services">注入服务</param>
        public CustomerController(IServiceCollection services)
        {
            _services = services;
        }
        /// <summary>
        /// 网关测试接口
        /// </summary>
        /// <returns>测试结果</returns>
        [HttpGet]
        public IActionResult Index()
        {
            return Ok(DateTime.Now);
        }
        ///// <summary>
        ///// 订阅
        ///// </summary>
        ///// <param name="order">要接收的对象</param>
        //[NonAction]
        //[CapSubscribe(" OrderCreated")]
        //public void HandleMessage(string order)
        //{
        //    //var json = Newtonsoft.Json.JsonConvert.SerializeObject(order);
        //    Console.Write(DateTime.Now.ToString() + "收到消息:" + order);
        //}
        /// <summary>
        /// 订阅
        /// </summary>
        /// <param name="order">要接收的对象</param>
        [NonAction]
        [CapSubscribe("OrderCreated")]
        public void CheckReceivedMessage(InputLogin order)
        {
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(order);
            Console.WriteLine(json);
        }
    }
}
